﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TEST0421
{
    class Graphic
    {
        protected string Type { get; set; }
        protected double peri;
        protected double area;

        public void GetValue()
        {
            Console.WriteLine("图形:{0}\n周长:{1}\n面积{2}", Type, peri, area);

        } 
    }
    //三角形
    class Triangle : Graphic
    {
        public double L1 { get; set; }
        public double L2 { get; set; }
        public double L3 { get; set; }

        public void Calculate()
        {
            Type = "三角形";
            peri = L1 + L2 + L3;
            double p = peri / 2;
            area = Math.Sqrt(p * (p - L1) * (p - L2) * (p - L3));
        }
    }
    //四边形
    class quadrangle : Graphic
    {
        public double Length { get; set; }
        public double Wideth { get; set; }

        public void Calculate()
        {
            Type = "四边形";
            peri = (Length + Wideth)*2;
            area = Length * Wideth;
        }
    }

    //圆形
    class Circle : Graphic
    {
        public double Radius { get; set; }

        public void Calculate()
        {
            Type = "圆形";
            peri = 2 * 3.14 * Radius;
            area = 3.14 * Radius * Radius;
        }

    }
}
